<!DOCTYPE html>
<html>
<head>
   <meta charset="utf-8">
</head>
<body>
    <input type="text" name="sousuo" id="s">

    <script>
        s.focus();
    </script>
    <hr>
    <button onclick="selectAll()">全选</button>
    <button onclick="copyAll()">全选复制</button>
    <button class="btn" data-clipboard-target="#content">复制</button>


   <textarea name="weibo" id="content" cols="50" rows="20">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Cumque provident dignissimos vitae recusandae, quae tempore necessitatibus, id labore officia nesciunt, aliquam iure unde minima amet impedit magnam libero cum maxime a nisi adipisci obcaecati omnis. Accusamus, modi voluptatem. Voluptate dolore provident, cum sequi pariatur modi repudiandae doloremque veniam corrupti voluptatem repellendus dignissimos. Eligendi voluptatum ut ipsum iusto similique quae, repudiandae repellat omnis minima ipsa expedita dignissimos nisi id consectetur a sequi doloremque quidem eveniet porro, libero excepturi rerum fuga animi iure. Repellat aperiam ea quis ipsa odio saepe beatae magni voluptate. Maiores aliquid quod voluptate aut obcaecati ipsum alias quidem!</textarea>


   <script src="../dist/clipboard.min.js"></script>

   <script>
        function selectAll(){
            content.select();
        }


        function copyAll(){
            if(window.cilpboardData)
            {
                clipboardData.setData("text",content.value);
                alert("已复制");
            }
            else
            {
                content.select();
                alert("按ctrl+c复制");
            }
        }

        var clipboard = new ClipboardJS(".btn");
        clipboard.on("success",function(e){
            alert("已复制");
            console.log(e);
        })
   </script>
</body>
</html>